package com.douya.common.pojo.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.douya.common.converter.BooleanConverter;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;

import java.time.LocalDateTime;

/**
 * 基础数据库实体类
 *
 * @Author hcy
 * @Date 2022/10/18
 */
@Data
@ToString(callSuper = true)
@Accessors(chain = true)
public class BaseEntity {

    /**
     * ID
     */
    @TableId(type = IdType.ASSIGN_ID)
    Long id;

    /**
     * 是否被删除
     */
    @TableLogic
    @TableField(value = "is_deleted", typeHandler = BooleanConverter.class)
    Boolean deleted;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    LocalDateTime updateTime;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    LocalDateTime createTime;

    /**
     * 备注
     */
    @TableField("remarks")
    String remarks;
}
